<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link rel="stylesheet" href="../../static/bootstrap/css/bootstrap.min.css" />
	<link rel="stylesheet" href="../../static/css/patient.css" />
	<link rel="stylesheet" href="../../static/css/global.css" />
	<title>处方查看页</title>
</head>

<body>
	<div th:replace="~{homepageFP::patNav}"></div>
	<main class="mainBox">
		<div class="container">
			<header class="mb-5">
				<div class="input-group mb-3">
					<input id="medId" type="text" class="form-control" placeholder="通过挂诊编号查询">
					<button class="btn btn-outline-secondary" type="button" onclick="findbyMedId()">查询</button>
				</div>
				<div class="input-group mb-3">
					<input id="idcard" type="text" class="form-control" placeholder="通过身份证号查询">
					<button class="btn btn-outline-secondary" type="button" onclick="findbyPatId()">查询</button>
				</div>
			</header>
			<section id="PrescriptionList" th:fragment="PrescriptionList">
				<div th:each="list : ${PrescriptionList}" th:if="${PrescriptionList!=null}" class="shadow-sm mb-3 p-3">
					<p>挂号编号：[[${list.medicalRecordId}]]</p>
					<p>诊断结果：[[${list.diagnosis}]]</p>
					<p>治疗方案：[[${list.advices}]]</p>
					<p>处方药物：[[${list.prescription}]]</p>
					<p>创建时间：[[${list.createTime}]]</p>
					<p>处方状态：
						<span class="text-success-emphasis" th:if="${list.finishTime!=null}">已完结</span>
						<span class="text-primary-emphasis" th:if="${list.finishTime==null}">进行中</span>
					</p>
				</div>
				<div class="text-center" th:if="${PrescriptionList==null}">没有数据哦~</div>
			</section>

		</div>
	</main>
	<script src="../../static/bootstrap/js/bootstrap.bundle.min.js"></script>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
	<script type="text/javascript">
		const findbyMedId = () => {
			let medicalId = document.getElementById("medId").value;
			$("#PrescriptionList").load(
				`/prescription?medicalId=${medicalId}`
			);
		}
		const findbyPatId = () => {
			let idcard = document.getElementById("idcard").value;
			$("#PrescriptionList").load(
				`/prescription?idcard=${idcard}`
			);
		}
	</script>
</body>

</html>